package com.aismy.admin.config;

import com.aismy.admin.interceptor.AuthInterceptor;
import com.aismy.admin.utils.JwtUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@RequiredArgsConstructor
public class WebConfig implements WebMvcConfigurer {
    private final JwtUtils jwtUtils;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new AuthInterceptor(jwtUtils))
                .addPathPatterns("/**")  // 拦截所有请求
                .excludePathPatterns(    // 排除不需要登录的路径
                        "/api/auth/login",    // 登录接口
                        "/api/auth/register", // 注册接口
                        "/api/file/download/*"

                );
    }
} 